'use strict';

const Controller = require('egg').Controller;

class seller extends Controller {




    async sellerPhoneLogin(ctx) {
        let encode = ctx.request.body.encode
        let phoneNumber = ctx.request.body.phoneNumber
        let code = ctx.request.body.code
        var login = await ctx.service.seller.sellerPhoneLogin(encode, phoneNumber, code)
        ctx.body = login
    }


 


     async  updateSellerName(ctx) {

         let id = ctx.request.body.id
         let name = ctx.request.body.name
         let origin_name = ctx.request.body.origin_name
         let update_name = ctx.request.body.update_name

        var information = await ctx.service.seller.updateSellerName(id,origin_name,update_name)

        ctx.body = information
    }


    async  addGoodsTeam(ctx) {
        let teamName = ctx.request.body.teamName
        let sell_id = ctx.request.body.sell_id
        let goodsLogo = ctx.request.body.goodsLogo
        let type = ctx.request.body.type
        var information = await ctx.service.seller.addGoodsTeam(teamName, sell_id, goodsLogo,type)
        ctx.body = information
    }



    async  getStayDetail(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getStayDetail(id)
        ctx.body = information
    }


  async  updateGoodsName(ctx) {

        let id = ctx.query.id
        let sid = ctx.query.sid
        let originName = ctx.query.originName
        let updateName = ctx.query.updateName


        var information = await ctx.service.seller.updateGoodsName(id,sid, originName, updateName)
        ctx.body = information
    }


  async  getUpdateName(ctx) {

        let id = ctx.query.id
        var information = await ctx.service.seller.getUpdateName(id)
        ctx.body = information
    }

   async  getRecord(ctx) {

        let id = ctx.query.id
        let type = ctx.query.type
        var information = await ctx.service.seller.getRecord(id,type)
        ctx.body = information
    }



   async addNewOtherGoodsItem(ctx) {
        let name = ctx.request.body.name
        let goodsLogo = ctx.request.body.goodsLogo
        let description = ctx.request.body.description
        let orderPrice = ctx.request.body.orderPrice
        let price = ctx.request.body.price
        let type = ctx.request.body.type
        let consumeValue = ctx.request.body.consumeValue
        let comeValue = ctx.request.body.comeValue
        let bedSize = ctx.request.body.bedSize
        let backValue = ctx.request.body.backValue
        let otherValue = ctx.request.body.otherValue
        let basicServer = ctx.request.body.basicServer
        let sellerType = ctx.request.body.sellerType
        let goods =  ctx.request.body.goods
        let updateFlag =  ctx.request.body.updateFlag
       let gid =  ctx.request.body.gid

        var information = await ctx.service.seller.addNewOtherGoodsItem(name, goodsLogo, description, orderPrice, price, type, consumeValue, comeValue, bedSize, backValue, otherValue,basicServer,sellerType,goods,updateFlag,gid)
        ctx.body = information
    }



 async saveTripSeller(ctx) {
        let type = ctx.request.body.type
        let tripName = ctx.request.body.tripName
        let mobile = ctx.request.body.mobile
        let selProvince = ctx.request.body.selProvince
        let selDistrict = ctx.request.body.selDistrict
        let selCity = ctx.request.body.selCity
        let address = ctx.request.body.address
        let tripType = ctx.request.body.tripType
        let minPrice = ctx.request.body.minPrice
        let maxPrice = ctx.request.body.maxPrice
        let intro = ctx.request.body.intro
        let imgList = ctx.request.body.imgList
        let businessLicence = ctx.request.body.businessLicence
        let idFront = ctx.request.body.idFront
        let idBack = ctx.request.body.idBack
        let linkMan = ctx.request.body.linkMan
        let email = ctx.request.body.email
        let sellerPhone = ctx.request.body.sellerPhone
        let textCode = ctx.request.body.textCode
        let uid = ctx.request.body.uid
        let encode = ctx.request.body.encode
        let avatar = ctx.request.body.avatar
        let addressInfo = ctx.request.body.addressInfo
        var trip = await ctx.service.user.saveTripSeller(tripName, mobile, selProvince, selCity, selDistrict, address, tripType, minPrice, maxPrice, intro, imgList, businessLicence, idFront, idBack, linkMan, email, sellerPhone, textCode, uid, encode, avatar,addressInfo,type)

        ctx.body = trip
    }
      async getSellCoupon(ctx) {
        let sid = ctx.query.sid
        var information = await ctx.service.seller.getSellCoupon(sid)
        ctx.body = information
    }

    async testOrderCode(ctx) {

        let code = ctx.query.code
        let seller_id = ctx.query.seller_id
        let sellerType =  ctx.query.sellerType
        var information = await ctx.service.seller.testOrderCode(code,seller_id,sellerType)
        ctx.body = information

    }


    async getSellGoodsMessage(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getSellGoodsMessage(id)
        ctx.body = information
    }


    async getAllGoods(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getAllGoods(id)
        ctx.body = information
    }

   async deleteGoodsName(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.deleteGoodsName(id)
        ctx.body = information
    }


   async deleteGoodsItem(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.deleteGoodsItem(id)
        ctx.body = information
    }



     async  getSelfActivity(ctx) {
        let sid = ctx.query.sid
        var information = await ctx.service.seller.getSelfActivity(sid)
        ctx.body = information
    }



    async  addSellerJoinActivity(ctx) {
        let aid = ctx.query.aid
        let newUser = ctx.query.newUser
        let count = ctx.query.count
        let discountPrice = ctx.query.discountPrice
        let gid = ctx.query.gid
        let sell_id = ctx.query.sell_id
        let sell_name = ctx.query.sell_name
        let beginTime= ctx.query.beginTime
        let endTime = ctx.query.endTime
        var information = await ctx.service.seller.addSellerJoinActivity(newUser, count, discountPrice,gid,sell_id,beginTime,endTime,aid,sell_name)
        ctx.body = information
    }

    async addNewGoodsItem(ctx) {
        let name = ctx.request.body.name
        let goodsLogo = ctx.request.body.goodsLogo
        let description = ctx.request.body.description
        let orderPrice = ctx.request.body.orderPrice
        let price = ctx.request.body.price
        let type = ctx.request.body.type
       let goods =  ctx.request.body.goods
       let updateFlag = ctx.request.body.updateFlag
       let fid =  ctx.request.body.fid
        var information = await ctx.service.seller.addNewGoodsItem(name, goodsLogo, description, orderPrice, price, type,goods,updateFlag,fid)
        ctx.body = information
    }
  
    async  goodsOffLine(ctx) {

        let goods_id = ctx.query.goods_id

        var information = await ctx.service.seller.goodsOffLine(goods_id)
        ctx.body = information
    }



    async  getGoodsItem(ctx) {

        let sell_id = ctx.query.sid
        let type = ctx.query.type
        var information = await ctx.service.seller.getGoodsItem(sell_id, type)
        ctx.body = information
    }


   async  addGoodsItem(ctx) {

        let sell_id = ctx.request.body.sell_id
        let teamName = ctx.request.body.teamName
        let goodsLogo = ctx.request.body.goodsLogo
        let selectedFood = ctx.request.body.selectedFood

        var information = await ctx.service.seller.addGoodsItem(sell_id, teamName, goodsLogo, selectedFood)
        ctx.body = information
    }



    async  addSellerDetailInfo(ctx) {

        let sell_id = ctx.request.body.sell_id
        let wifi = ctx.request.body.wifi
        let piao = ctx.request.body.piao
        let pack = ctx.request.body.pack
        let distanceNumber = ctx.request.body.distanceNumber
        let peopleNumber = ctx.request.body.peopleNumber
        let distanceStatus = ctx.request.body.distanceStatus
        let peopleStatus = ctx.request.body.peopleStatus
        let couponStatus = ctx.request.body.couponStatus
        let couponText = ctx.request.body.couponText
        let send = ctx.request.body.send
        let moneyText = ctx.request.body.moneyText
        let feeNumber = ctx.request.body.feeNumber
        let  feeStatus = ctx.request.body.feeStatus
        let  sellerType = ctx.request.body.sellerType
        let  orderText = ctx.request.body.orderText
        let  bulletin = ctx.request.body.bulletin
     
        var information = await ctx.service.seller.addSellerDetailInfo(sell_id, wifi, piao, pack, distanceNumber,peopleStatus,peopleNumber,distanceStatus,couponStatus,couponText,send,moneyText, feeNumber, feeStatus ,sellerType,orderText,bulletin)
        ctx.body = information
    }

   async  addSellerServer(ctx) {

       let sell_id = ctx.request.body.sell_id
        let send = ctx.request.body.send
        let distanceNumber = ctx.request.body.distanceNumber
        let peopleStatus = ctx.request.body.peopleStatus
        let peopleNumber = ctx.request.body.peopleNumber
        let distanceStatus = ctx.request.body.distanceStatus
        let area = ctx.request.body.area
        let cookCount = ctx.request.body.cookCount
        let pNumber = ctx.request.body.pNumber
        let bedNumber = ctx.request.body.bedNumber
        let otherServer = ctx.request.body.otherServer
        let basicServer = ctx.request.body.basicServer
        let showerServer = ctx.request.body.showerServer
        let cookServer = ctx.request.body.cookServer
        let homeServer = ctx.request.body.homeServer
        let inType = ctx.request.body.inType
        let inTime = ctx.request.body.inTime
        let leftTime = ctx.request.body.leftTime
        let supportReturn = ctx.request.body.supportReturn
        let noReturn = ctx.request.body.noReturn
        let pass = ctx.request.body.pass
        let bed = ctx.request.body.bed
        let allTime = ctx.request.body.allTime
        let couponStatus = ctx.request.body.couponStatus
        let couponText = ctx.request.body.couponText 
        let bulletin = ctx.request.body.bulletin
           
        var information = await ctx.service.seller.addSellerServer(sell_id, send,pass,bed,allTime, distanceNumber, peopleStatus, peopleNumber, distanceStatus, area, cookCount, pNumber, bedNumber, otherServer, basicServer, showerServer, cookServer, homeServer, inType, inTime, leftTime, supportReturn, noReturn,couponStatus,couponText,bulletin)
        ctx.body = information
    }




     async getAuthSeller(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getAuthSeller(id)
        ctx.body = information
    }



   async sellerAggreeDocument(ctx) {
        let id = ctx.query.id
        let type = ctx.query.type
        var information = await ctx.service.seller.sellerAggreeDocument(id,type)
        ctx.body = information
    }

 
    async sellerAuthName(ctx) {

        let sell_id = ctx.request.body.sell_id
        let encode = ctx.request.body.encode
        let phone = ctx.request.body.phone
        let code = ctx.request.body.code
        let seller_name = ctx.request.body.seller_name
        let id_code = ctx.request.body.id_code
        let credit_card = ctx.request.body.credit_card
        var information = await ctx.service.seller.sellerAuthName(sell_id, encode, phone, code, seller_name, id_code, credit_card)
        ctx.body = information
    }


   async updateSellerDiscountStatus(ctx) {
        let cid = ctx.query.cid
        var information = await ctx.service.seller.updateSellerDiscountStatus(cid)
        ctx.body = information
    }


   async throughSellerAuth(ctx) {
        let sid = ctx.query.sid
        var information = await ctx.service.seller.throughSellerAuth(sid)
        ctx.body = information
    }


    async getSellerActivity(ctx) {
        let time = ctx.query.time
        let type = ctx.query.type
        var information = await ctx.service.seller.getSellerActivity(time,type)
        ctx.body = information
    }

      async getDateSellMessage(ctx) {
        let id = ctx.query.id

        let startTime = ctx.query.beginTime
        let endTime = ctx.query.endTime
        let beforeEndTime = ctx.query.beforeEndTime
        let beforeStartTime = ctx.query.beforeStartTime
        var information = await ctx.service.seller.getDateSellMessage(id, startTime, endTime,beforeStartTime,beforeEndTime)
        ctx.body = information
    }



      async updateSellDiscount(ctx) {
        let sid = ctx.request.body.sid
        let price = ctx.request.body.price
        let discount = ctx.request.body.discount
        let type = ctx.request.body.type
        let update = ctx.request.body.update
        let start_time = ctx.request.body.start_time
        let end_time = ctx.request.body.end_time
        let description = ctx.request.body.description
        var information = await ctx.service.seller.updateSellDiscount(sid, price, discount, type, update, start_time, end_time,description)
        ctx.body = information
    }

      async addReply(ctx) {
        let cid = ctx.query.cid
        let content = ctx.query.content
        var information = await ctx.service.seller.addReply(cid, content)
        ctx.body = information
    }



      async getSellerCoupon(ctx) {
        let id = ctx.query.id
        let status = ctx.query.status
        var information = await ctx.service.seller.getSellerCoupon(id, status)
        ctx.body = information
    }



  async getSellerRating(ctx) {

        let id = ctx.query.id
        let sellerType = ctx.query.sellerType
        let type = ctx.query.type
        let start = ctx.query.start

        var information = await ctx.service.seller.getSellerRating(id,sellerType,type,start)
        ctx.body = information
    }


      async getSale(ctx) {
        let id = ctx.query.sid
        var information = await ctx.service.seller.getSale(id)
        ctx.body = information
    }


       async sellerPunish(ctx) {
        let id = ctx.query.sid
        var information = await ctx.service.seller.sellerPunish(id)
        ctx.body = information
    }

 async getSellerNotice(ctx) {
        let id = ctx.query.sid
        var information = await ctx.service.seller.getSellerNotice(id)
        ctx.body = information
    }



    async updateSellerSend(ctx) {
        let sid = ctx.query.sid
        var information = await ctx.service.seller.updateSellerSend(sid)
        ctx.body = information
    }

    async getSellerImg(ctx) {
        let id = ctx.query.sid
        var information = await ctx.service.seller.getSellerImg(id)
        ctx.body = information
    }

    async getSellerAuthDetail(ctx) {
        let id = ctx.query.sid
        var information = await ctx.service.seller.getSellerAuthDetail(id)
        ctx.body = information
    }

   
    async  updateSellerImg(ctx) {
       let sid = ctx.request.body.sid
        let imgList = ctx.request.body.imgList
        let imgList1 = ctx.request.body.imgList1
        var information = await ctx.service.seller.updateSellerImg(sid,imgList, imgList1)
        ctx.body = information
    }

   async updateSellCoupon(ctx) {
        let sid = ctx.query.sid
        let limitPrice = ctx.query.limitPrice
        let discount = ctx.query.discount
        let type = ctx.query.type
        let update = ctx.query.update
        let description = ctx.query.description
       let end_time = ctx.query.end_time

        var information = await ctx.service.seller.updateSellCoupon(sid,limitPrice,discount,type,update,description,end_time)
        ctx.body = information
    }


       async  addFeedBack(ctx) {

        let text = ctx.request.body.text
        let type = ctx.request.body.type
        let phone = ctx.request.body.phone
        let imgs = ctx.request.body.imgs
        let postTime = ctx.request.body.postTime
        var information = await ctx.service.seller.addFeedBack(text, type, phone, imgs, postTime)
        ctx.body = information
    }


      async deleteSellCoupon(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.deleteSellCoupon(id)
        ctx.body = information
    }




  async  updateAddress(ctx) {
        let sid = ctx.request.body.sid
        let addressInfo = ctx.request.body.addressInfo
        let selProvince = ctx.request.body.selProvince
        let address = ctx.request.body.address
         let selCity = ctx.request.body.selCity
        let selDistrict = ctx.request.body.selDistrict
        var information = await ctx.service.seller.updateAddress(sid,addressInfo, selProvince, address,selCity,selDistrict)
        ctx.body = information
    }
 
    async changeConsumerType(ctx) {
        let sid = ctx.query.sid
        let type = ctx.query.type
        var information = await ctx.service.seller.changeConsumerType(sid, type)
        ctx.body = information
    }

   async updateSellTime(ctx) {
        let sid = ctx.query.sid
        let beginTime = ctx.query.beginTime
        let endTime = ctx.query.endTime
        var information = await ctx.service.seller.updateSellTime(sid,beginTime,endTime)
        ctx.body = information
    }


       async updateChildType(ctx) {
        let sid = ctx.query.sid
        let origin_type = ctx.query.origin_type
        let update_type = ctx.query.update_type
        var information = await ctx.service.seller.updateChildType(sid,update_type,origin_type)
        ctx.body = information
    }




    async updateSellTime(ctx) {
        let sid = ctx.query.sid
        let beginTime = ctx.query.beginTime
        let endTime = ctx.query.endTime
        var information = await ctx.service.seller.updateSellTime(sid,beginTime,endTime)
        ctx.body = information
    }

    async takeOrder(ctx) {
        let order_id = ctx.query.order_id
       let status = ctx.query.status
        var information = await ctx.service.seller.takeOrder(order_id,status)
        ctx.body = information
    }



    async changeSellerStatus(ctx) {
        let sid = ctx.query.sid
       let status = ctx.query.status
        var information = await ctx.service.seller.changeSellerStatus(sid,status)
        ctx.body = information
    }

 

    async haveConsumer(ctx) {
        let order_id = ctx.query.order_id
        let consumer_time =  ctx.query.consumer_time
        var information = await ctx.service.seller.haveConsumer(order_id,consumer_time)
        ctx.body = information
    }

     async  updateSellerPhone(ctx) {

        let id = ctx.request.body.id
         let phone = ctx.request.body.phone
        var information = await ctx.service.seller.updateSellerPhone(id,phone)
        ctx.body = information
    }


    async getSeller(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getSeller(id)
        ctx.body = information
    }



  async  updateInfoByPhone(ctx) {

        let encode = ctx.request.body.encode
        let phoneNumber = ctx.request.body.phoneNumber
        let code = ctx.request.body.code
         let sid = ctx.request.body.sid
        var information = await ctx.service.seller.updateInfoByPhone(encode, phoneNumber,code,sid)
        ctx.body = information
    }



     async saveSeller(ctx) {
        let name = ctx.request.body.name
        let type = ctx.request.body.type
        let licentCode = ctx.request.body.licentCode
        let licenName = ctx.request.body.licenName
        let sellerName = ctx.request.body.sellerName
        let sid = ctx.request.body.sid
        let address = ctx.request.body.address
        let phoneNumber = ctx.request.body.phoneNumber
        let province = ctx.request.body.province
        let city = ctx.request.body.city
        let district = ctx.request.body.district
        let status = ctx.request.body.status
        let businessLicence = ctx.request.body.businessLicence
        let idFront = ctx.request.body.idFront
        let idBack = ctx.request.body.idBack

        let linkMan = ctx.request.body.linkMan
        let textCode = ctx.request.body.textCode
        let encode = ctx.request.body.encode
        let idCode = ctx.request.body.idCode
        let uid = ctx.request.body.uid
       
        let adcode = ctx.request.body.adcode
       
        let lat = ctx.request.body.lat
        let lng = ctx.request.body.lng

        var save = await ctx.service.seller.saveSeller(sid,name,licentCode,licenName,sellerName,address,phoneNumber,province,city,status,district,businessLicence,idFront,idBack,linkMan,textCode,idCode,encode,uid,adcode,
lat,lng,type)
        ctx.body = save
    }



     async updateInfoByPs(ctx) {
         
        let newPs = ctx.request.body.newPs
        let oldPs = ctx.request.body.oldPs
        let sid = ctx.request.body.sid
        var update = await ctx.service.seller.updateInfoByPs(newPs, oldPs, sid)
        ctx.body = update
    }

    async sellerPsLogin(ctx) {
        
        let username = ctx.request.body.username
        let password = ctx.request.body.psword
      
        var login = await ctx.service.seller.sellerPsLogin(username,password)
        ctx.body = login
    }

    async getSellerInfo(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getSellerInfo(id)
        ctx.body = information
    }

    async  sellerAuthRegister(ctx) {

        let encode = ctx.request.body.encode
        let type = ctx.request.body.type
        let phoneNumber = ctx.request.body.phoneNumber
        let code = ctx.request.body.code
        let username = ctx.request.body.username
        let password = ctx.request.body.password
        var information = await ctx.service.seller.sellerAuthRegister(encode, phoneNumber, code,username,password,type)
        ctx.body = information
    }

    async getSellerNewOrder(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getSellerNewOrder(id)
        ctx.body = information
    }

    async getTodayMessage(ctx) {
        let sid = ctx.query.sid
        let beginTime = ctx.query.beginTime
        let endTime = ctx.query.endTime
        var information = await ctx.service.seller.getTodayMessage(sid, beginTime, endTime)
        ctx.body = information
    }


     async getInformation(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.getInformation(id)
        ctx.body = information
    }



    async getLearnHot(ctx) {
       
        var information = await ctx.service.seller.getLearnHot()
        ctx.body = information
    }

 

 async learnDetail(ctx) {
        let id = ctx.query.id
        var information = await ctx.service.seller.learnDetail(id)
        ctx.body = information
    }



    async getOrderById(ctx) {
        let order_id = ctx.query.order_id
        let seller_id = ctx.query.seller_id
        let sellerType = ctx.query.sellerType
        var order = await ctx.service.seller.getOrderById(order_id,seller_id,sellerType)
        ctx.body = order
    }

    async getSellerOrder(ctx) {
        let id = ctx.request.body.id
        let type = ctx.request.body.type
        let start = ctx.request.body.start
        let sellerType = ctx.request.body.sellerType
        var order = await ctx.service.seller.getSellerOrder(id, type, start,sellerType)
        ctx.body = order
    }



}

module.exports = seller
